package goleetcode

func maxConsecutiveAnswers(answerKey string, k int) int {
	cnt := [2]int{}
	left := 0
	ans := 0
	for right, ch := range answerKey {
		cnt[ch >> 1 & 1]++
		for cnt[0] > k && cnt[1] > k {
			cnt[answerKey[left] >> 1 & 1]--
			left++
		}
		ans = max(ans, right-left+1)
	}
	return ans
}